<template>
    <div class="container">
        <mt-header title="入住订单">
            <router-link to="/" slot="left">
                <mt-button icon="back"></mt-button>
            </router-link>
        </mt-header>
        <div class="body">
            <div @click="goDetail(item.id)" class="order" v-for="(item, index) in orderData" :key="index">

                <div class="order2">

                    <div class="img">
                        <img :src='baseUrl + item.cover' alt="">
                    </div>
                    <div class="right">
                        <span class="time">
                            {{ item.id }}
                            创建时间： {{ item.createTime }}
                        </span>
                        当前状态：{{ item.status }}
                        <div class="name">
                            {{ item.title }}
                        </div>
                        <div class="price">
                            ${{ item.total }}
                        </div>
                        <div class="id">
                            订单号：{{ item.orderNo }}
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            orderData: [],
            baseUrl: this.getBaseUrl(),
        }
    },
    methods: {
        getList() {
            this.$axios({
                url: this.$api.orderList,
                method: 'get',
                Headers: { Authorization: 'Bearer' + this.$store.state.token }
            }).then(res => {
                this.orderData = res.rows
                // console.log(this.orderData);
            })
        },
        goDetail(id) {
            this.$router.push({ path: '/orderDetail', query: { id: id } })
            // console.log(id);
        }
    },
    mounted() {
        this.getList()
    }

}
</script>

<style lang="scss" scoped>
* {
    margin: 0;
    padding: 0;
}

.body {
    display: flex;
    justify-content: space-around;
    flex-direction: column;
}

.order {
    height: auto;
    width: 95%;
    border-radius: 10px;
    background-color: #fff;
    margin: 0 auto;
    margin-top: 10px;
    padding-top: 10px;
    padding-bottom: 10px;

    .order2 {
        height: 120px;
        width: 90%;
        margin: 0 auto;
        display: flex;
        justify-content: space-evenly;
    }

    .img {
        width: 120px;
        height: 120px;
        line-height: 120px;

        img {
            width: 120px;
            height: 120px;
        }
    }

    .right {
        display: flex;
        justify-content: space-around;
        flex-direction: column;
    }

    .price {
        color: red;
    }

    .time {
        font-size: 10px;
    }

    .title {
        font-size: 15px;
    }

}
</style>